﻿using Padsurface.Audio.Song.Model;
using System;
using System.Windows.Input;

namespace Padsurface.App.ViewModels
{
    public class SoundViewModel
    {
        private readonly Sound _sound;
        private readonly Song _song;

        public string Name 
        { 
            get { return _sound.Name; } 
        }

        public SoundViewModel(Sound sound, Song song)
        {
            if (sound == null) throw new ArgumentNullException("sound");
            if (song == null) throw new ArgumentNullException("song");

            _sound = sound;
            _song = song;

            StartPlayingCommand = new DelegateCommand(StartPlaying);
        }

        #region StartPlayingCommand

        public ICommand StartPlayingCommand { get; set; }

        private void StartPlaying(object obj)
        {
            _sound.Play();

            if (_song.IsRecording)
                _song.Record(_sound);
        }

        #endregion

    }
}
